<template>
  <div class="detail-page">
    <el-page-header  @back="$router.back()" />
    <el-card v-if="detail" class="mt-4">
      
      <div class="order-track-page">
    <!-- 左侧：订单信息 -->
    <div class="order-track-left">
      <h3>订单信息</h3>
      <div class="order-info-card">
        <div>订单编号：{{ order.orderNo }} <el-link @click="copy(order.orderNo)" :underline="false">复制</el-link></div>
        <div>买家昵称：{{ order.buyerName }}</div>
        <div>收货地址：{{ order.receiver }}</div>
        <div>店铺信息：{{ order.shopInfo }}</div>
        <div>配送方式：{{ order.deliveryType }}</div>
        <div>配送员：<el-link type="primary">{{ order.riderName }}，{{ order.riderPhone }}</el-link></div>
        <div class="goods-list">
          <div v-for="(item, idx) in order.goods" :key="idx" class="goods-item">
            <img :src="item.img" class="goods-img" />
            <div>
              <div>{{ item.name }} <span style="color:#888;">({{ item.brand }})</span></div>
              <div class="goods-desc">规格：{{ item.spec }}，辣度：{{ item.spicy }}</div>
            </div>
            <div class="goods-qty">x{{ item.qty }}</div>
          </div>
        </div>
      </div>
    </div>

    <!-- 右侧：地图+配送状态+时间轴 -->
    <div class="order-track-right">
      <div class="map-card">
        <!-- 这里用高德/百度/腾讯地图JS API，示例用div占位 -->
        <div id="map" class="map-placeholder"></div>
        <div class="status-btns">
          <el-button v-for="(s, i) in statusList" :key="i" size="small" plain>{{ s }}</el-button>
        </div>
      </div>
      <div class="timeline-card">
        <el-timeline>
          <el-timeline-item
            v-for="(item, idx) in timeline"
            :key="idx"
            :timestamp="item.time"
            :type="item.type"
            :icon="item.icon"
            :color="item.color"
            placement="top"
          >
            <div>{{ item.title }}</div>
            <div class="timeline-desc">{{ item.desc }}</div>
          </el-timeline-item>
        </el-timeline>
      </div>
    </div>
  </div>




    </el-card>
    <el-empty v-else description="加载中…" />
  </div>
</template>

<script setup>
import { useRoute } from 'vue-router'
import { onMounted, ref } from 'vue'
import { getOrderDetail } from '@/api/order'

const { id } = useRoute().params
const detail = ref(null)


import { ElMessage } from 'element-plus'

// 示例数据
const order = {
  orderNo: '12232964103521',
  buyerName: '小聚123',
  receiver: '李四收，+8613612345678，广东省深圳市龙华区民治街道第十一区101栋2101室',
  shopInfo: '小八安全枕榴莲披萨(风凰广场店)，+8613612345678，广东省深圳市龙华区民治街道第九区308栋1楼',
  deliveryType: '平台专送',
  riderName: '王骑手',
  riderPhone: '+8613612345678',
  goods: [
    { img: 'https://img.example.com/1.jpg', name: '小龙虾', brand: '全家', spec: '五斤', spicy: '变态辣', qty: 1 },
    { img: 'https://img.example.com/2.jpg', name: '老字号捞粉', brand: '', spec: '', spicy: '', qty: 2 },
    { img: 'https://img.example.com/1.jpg', name: '小龙虾', brand: '全家', spec: '五斤', spicy: '变态辣', qty: 1 },
    { img: 'https://img.example.com/3.jpg', name: '老字号猪米粉', brand: '', spec: '', spicy: '', qty: 2 }
  ]
}

const statusList = [
  '等待骑手接单', '骑手未到店', '骑手到店', '骑手配送中', '骑手配送超时', '骑手已送达', '交易取消/关闭'
]

const timeline = [
  { time: '2022-10-08/周二 23:39:10', title: '等待骑手接单', desc: '', type: 'danger', icon: 'el-icon-warning', color: '#f56c6c' },
  { time: '23:39:10', title: '商家已接单', desc: '商家备货中', type: 'primary' },
  { time: '23:37:55', title: '支付成功', desc: '订单在线付款成功', type: 'success' },
  { time: '23:37:35', title: '顾客提交订单', desc: '预计送达：03-09 00:05', type: '' }
]

// 复制功能
function copy(text) {
  navigator.clipboard.writeText(text)
  ElMessage.success('复制成功')
}

</script>


<style scoped>
.order-track-page {
  display: flex;
  gap: 24px;
  margin: 24px 0;
}
.order-track-left, .order-track-right {
  flex: 1;
}
.order-info-card, .map-card, .timeline-card {
  background: #f7faff;
  border-radius: 12px;
  padding: 18px 22px 14px 22px;
  margin-bottom: 18px;
  box-shadow: 0 2px 8px #f0f1f2;
}
.goods-list {
  margin-top: 16px;
}
.goods-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.goods-img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid #eee;
  margin-right: 12px;
}
.goods-desc {
  font-size: 13px;
  color: #888;
}
.goods-qty {
  margin-left: auto;
  font-weight: 500;
  font-size: 16px;
}
.map-placeholder {
  width: 100%;
  height: 180px;
  background: #e4e7ed;
  border-radius: 8px;
  margin-bottom: 12px;
}
.status-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: absolute;
  right: 18px;
  top: 18px;
}
.map-card {
  position: relative;
  min-height: 200px;
}
.timeline-card {
  margin-top: 18px;
}
.timeline-desc {
  color: #888;
  font-size: 13px;
}
</style>